import axios from '@/api/fetch';
import * as types from './types';
import SERVER from '@/api/server';

// 查询车主信息
export const updateRepairWhenCustomerChange = params => axios.post(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/customerCare/ownerVehicleManagement/updateRepairWhenCustomerChange`, params);

// 查询车主信息
export const getOwnerInfo = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/owner/findAll`, { params });

// 查询车主信息BY ownerNo dealerCode
export const getOwnerInfoByOwnerNoAndDealerCode = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/customerCare/ownerVehicleManagement/getOwnerInfoByOwnerNoAndDealerCode`, { params });

// 查询车主信息BY 证件类型，证件号码
export const getOwnerInfoByCertificate = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/customerCare/ownerVehicleManagement/getOwnerInfoByCertificate`, { params });

// // 查询车主联系人信息BY ownerNo dealerCode
// export const getOwnerLinkerInfo = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/vehicle/`, { params });

// 查询车主联系人信息不分页
export const getOwnerLinkerInfoAll = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/customerCare/ownerVehicleManagement/getOwnerLinkerInfoAll`, { params });
// 新增车主
export const addOwner = params => axios.post(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/owner/save`, params, { mark: types.SAVE });

// 修改车主
export const updateOwner = (id, params) => axios.post(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/customerCare/ownerVehicleManagement/updateOwner/${id}`, params);

// 查询车辆信息
export const getVehicleInfo = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/vehicle/findAll`, { params }); // timeout: 600000 设置为10分钟 7万条数据 返回157MB时后端服务内存溢出崩溃 故去除

// 查询厂端车辆信息
export const getVehicleInfoOEM = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/vehicle/findAllOEM`, { params }); // timeout: 600000 设置为10分钟 7万条数据 返回157MB时后端服务内存溢出崩溃 故去除

// 查询车辆信息 BY vin dealerCode
export const getVehicleInfoByVinAndDealerCode = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/customerCare/ownerVehicleManagement/getVehicleInfoByVinAndDealerCode`, { params });

// 新增车辆
export const addVehicle = params => axios.post(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/vehicle/save`, params, { mark: types.SAVE });

// 修改车辆
export const updateVehicle = (id, params) => axios.post(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/customerCare/ownerVehicleManagement/updateVehicle/${id}`, params, { mark: types.SAVE });

// 省
export const getProvince = params => axios.get(`/api/basedata/region/listAllProvice`);

// 市
export const getCitys = provinceId => axios.get(`/api/basedata/region/listCityByProviceId/${provinceId}`);

// 县
export const getDistrict = cityId => axios.get(`/api/basedata/region/listCityByProviceId/${cityId}`);

//
export const getRegion = params => axios.get(`/api/basedata/region//listAllData`, { params });

// 根据地区ID拿邮编
export const getPostCode = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/baseData/queryPostCode`, { params });

// 服务顾问
export const getServiceAdvisor = params => axios.get(`/api/sysManage/basedata/users/getUserListByRole?role=10061011`);

// 指定技师
export const getChiefTechnician = params => axios.get(`/api/sysManage/basedata/users/getUserListByRole?role=10061012`);

// dcrc客服专员
export const getDcrcAdvisor = params => axios.get(`/api/sysManage/basedata/users/getUserListByRole?role=10061017`);

// 续保专员
export const getInsuranceAdvisor = params => axios.get(`/api/sysManage/basedata/users/getUserListByRole?role=10061015`);

// 定保专员
export const getMaintainAdvisor = params => axios.get(`/api/sysManage/basedata/users/getUserListByRole?role=10061016`);

// 车主信息导出
// export const getOwnerExcelList = params =>
//   axios.get(`${SERVER.DMSCLOUD_REPAIR}/customerCare/ownerVehicleManagement/getOwnerInfo/export/excel`, { params, responseType: 'arraybuffer', timeout: 100000 });
export const getOwnerExcelList = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/owner/export`, { params, responseType: 'blob' });

// 车辆信息导出
export const getVehicleExcelList = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/vehicle/export`, { params, responseType: 'blob' });

// 车辆信息导出
export const getVehicleExcelOEMList = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/vehicle/exportOEM`, { params, responseType: 'blob' });

// 优惠模式下拉框
export const getdiscountModeIdList = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/customerCare/ownerVehicleManagement/getdiscountModeIdList`, { params });

// 发票类型下拉框
export const DMSCLOUD_CUSTOMERREPAIR = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/customerCare/ownerVehicleManagement/DMSCLOUD_CUSTOMERREPAIR`, { params });

// 查询车辆的保险信息
export const getInsuranceInfo = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicle/insProposal/vehicleGetInsuranceInfo`, { params });

// 颜色下拉框
export const getColorList = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/customerCare/ownerVehicleManagement/getColorList`, { params });

// 颜色搜索帮助
export const getColorByPage = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/customerCare/ownerVehicleManagement/getColorByPage`, { params });

// 获取会员信息
export const getMembersInfo = params => axios.get(`${SERVER.MEMBERS_CLUB}/membersInterface/getMembersInfo`, { params });

// 获取底盘号下在修状态工单
export const getUnderRepairRecordCount = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/customerCare/ownerVehicleManagement/getUnderRepairRecordCount`, { params });

// 查询全部经销商信息
export const queryAllDealerInfo = params => axios.get(`${SERVER.SYSMANAGE}/company/org/getAllCompanyIdName`);

// 查询销售车辆信息列表（搜索条件VIN为非模糊查询）
export const getVins = params => axios.get(`${SERVER.RETAIL}/saleAfterInter/getVehilceOwnerDataForHtml`, { params });

// 查询潜客信息
export const getPotentialInfo = params => axios.get(`${SERVER.CYXDMS_CLUE}/ApiPotentialForSaleAfter/afterSalesInquiryFollowup`, { params });

// OEM维修历史查询--厂端客户查询维修历史
export const queryOEMRepairHistory = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/order/repairOrder/queryOEMRepairHistoryRepairCustomer`, { params });

// 厂端客户查询--查询索赔历史
export const queryClaimHistory = params => axios.post(`${SERVER.CLAIMFAC}/rPCmsClaim/selectClaimLogByExample`, params);

// 厂端客户查询--查询索赔历史明细
export const queryClaimHistoryDetail = params => axios.get(`${SERVER.CLAIMFAC}/rPCmsClaim/selectDetailByClaimNo`, { params });

// 厂端客户查询--导出索赔历史
export const exportClaimLogByExample = params => axios.post(`${SERVER.CLAIMFAC}/rPCmsClaim/exportClaimLogByExample`, params, { responseType: 'blob' });

// 客户查询--查询欠款金额
export const queryOwnerAmountwed = params => axios.get(`${SERVER.DMSCLOUD_FINANCE}/customerRepairBussiness/queryOwnerAmountwed`, { params });

// 查询预收款
export const queryPrePayByOwnerNo = params => axios.get(`${SERVER.DMSCLOUD_FINANCE}/preReceiveMoney/queryPrePayByOwnerNo`, { params });

//车主厂端查询--查询联系人信息
export const queryLinkInfoByOwnerNo = params => axios.get(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/owner/queryLinkInfoByOwnerNo`, { params });

// 新增经销商车主
export const saveDealerOwner = params => axios.post(`${SERVER.DMSCLOUD_CUSTOMERREPAIR}/vehicleOwnerManagement/owner/saveDealerOwner`);

// 查询车主车辆组合信息
export const getOwnerAndVehicleInfo = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/vehicleOwnerManagement/ownerAndVehicle/findAllOfPage`, { params });

//车主车辆组合信息导出
export const exportOwnerAndVehicleInfo = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/vehicleOwnerManagement/ownerAndVehicle/exportOwnerAndVehicleInfo`, { params, responseType: 'blob' });

export const exportMaintainList = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/vehicleOwnerManagement/ownerAndVehicle/exportMaintainList`, params, { responseType: 'blob' });

//通过ID查
export const selectById = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/vehicleOwnerManagement/ownerAndVehicle/selectMaintainById/${params.vin}`);

//维护更新
export const updateMaintain = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/vehicleOwnerManagement/ownerAndVehicle/maintain/updateByVin`,  params );

// 查询车主车辆组合信息
export const getOwnerAndVehicleInfoNew = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/vehicleOwnerManagement/ownerAndVehicle/findAllOfPageNew`, { params });
